<?php
/**
 * Display Contact Document List
 *
 * @package Contact
 */
use Fox\Generator;
use Fox\Grid\FieldCat\Field\Renderer\Anchor;
$id = $params['id'];
$blkcv = new Fox\Html\Block("bDocs",Msg(Hive::BUNDLE,Hive::MENU_DOCUMENTS));
$blkcv->collapsed(false);
$grid = new Fox\Grid("documents",Generator::url("missions","documents",null,array("mid" => $id)));
$grid->fieldcat(array("filename","doctype","uname","udate","export","idele"));
$grid->fieldcat()->switchToObjectMode();
$grid->fieldcat()->field("udate")->displayTime();

$grid->fieldcat()->field("filename")
	->openAsNewPage(true)
	->renderers(new Anchor(Generator::url("core","files","download",
		array('xvtrs' => 'none','docid' => Fox\Generator::useAttribute()))));

$grid->fieldcat()->field("export")->noOutput();
$grid->fieldcat()->setGenerators(array(
	"export" => Fox\Generator::url(
		"core",
		"files",
		"download",
		array("docid" => Fox\Generator::useAttribute('id'),
			 "xvtrs" => Fox\Generator::useValue("none"))
	),
	"idele" => Fox\Generator::display('POP_ORD_VALID', Fox\Generator::url(
		"missions",
		"documents",
		"delete",
		array(
			"docid" => Fox\Generator::useAttribute('docid'),
			"missionid" => Fox\Generator::useValue($id)
		)
	)),
	"doctype" => Fox\Generator::useFunction(function($data) {
		return $data->doctype()->description;
	})
));
$blkcv->add($grid);
return $blkcv;